{extend name="./oscshop/admin/view/public/base.html" /}
{block name="content"}
<div class="page-header">
	<h1>	
		{$breadcrumb1}
		<small>
			<i class="ace-icon fa fa-angle-double-right"></i>
			{$breadcrumb2}
		</small>
	</h1>
</div>

<form action="{:url('Free/apply')}" method="get">
	<table class="table table-striped table-bordered table-hover">
		<thead>
		<tr>
			<th>
				<input name="username" type="number" placeholder="输入用户名" value="{:input('param.username')}" />
				<input name="sub_date" type="date" placeholder="输入时间" value="{:input('param.sub_date')}" />
				<button class="btn btn-primary">查询</button>&nbsp;&nbsp;&nbsp;
				<a href="{:url('Free/apply')}" class="btn btn-primary">清空查询条件</a>
				&nbsp;&nbsp;&nbsp;
			</th>
		</tr>
		</thead>
	</table>
</form>

<form action="{:url('Free/create')}" method="post">
	<table class="table table-striped table-bordered table-hover">
		<thead>
		<tr>
			<th>
				交易品种
				<select name="exchange_id" id ="exchange_id"   tabindex="4">
							<option value ="-1">请选择交易所</option>
							{volist name="exchange" id="p" empty="$exchange"}
							<option value ="{$p.id}">{$p.name}</option>
							{/volist}
				</select>

				<select name="variety_id" id ="variety_id"   tabindex="4">
							<option value ="-1">请选择交易品种</option>
							{volist name="variety" id="p" empty="$variety"}
							<option value ="{$p.id}">{$p.name}</option>
							{/volist}
				</select>
				&nbsp;&nbsp;&nbsp;
				<button class="btn btn-primary">批量审批</button>
				&nbsp;&nbsp;&nbsp;
				<span>抵扣金豆额：{$sum1}</span>
				&nbsp;&nbsp;&nbsp;
				<span>抵扣元宝额：{$sum2}</span>
				&nbsp;&nbsp;&nbsp;
				<span>总申总额：{$sum3}</span>

			</th>
		</tr>
		</thead>
	</table>

<div class="row">
	<div class="col-xs-12">	
		<div class="table-responsive">
			<table id="con_table" class="table table-striped table-bordered table-hover">
				<thead>
					<tr>
						<th><input type="checkbox" id="all1" value="1" /></th>
					    <th>ID</th>
						<th>用户</th>
						<th>姓名</th>
						<th>申请金额</th>
						<th>抵扣额</th>
						<th>抵扣方式</th>
						<th>申请时间</th>
					</tr>
				</thead>
				<tbody>
					{volist name="list" id="v"}
					<tr>
						<td><input type="checkbox" name="all[]"   id="list" value="{$v.id}" /></td>
						<td>{$v.id}</td>
						<td>{$v.username}</td>
						<td>{$v.idcardname}</td>
						<td>{$v.money}</td>
						<td>{$v.price}</td>
						<td>{if condition="$v.type eq 1"}金豆{else}元宝{/if}</td>
						<td>{$v.sub_date}</td>
					</tr>
					{/volist}
				</tbody>
				
			</table>
		</div>
		{$page}
		</form>
	</div>
</div>
{/block}
{block name="javascript"}
<script>	
$(function(){
   $("#search").click(function () {
        var url = $(this).attr('url');
        var query = $('.search-form').find('input,select').serialize();
        query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
        query = query.replace(/^&/g, '');
        if (url.indexOf('?') > 0) {
            url += '&' + query;
        } else {
            url += '?' + query;
        }
        window.location.href = url;
    });	
});
</script>

<script type="text/javascript">
    $('#exchange_id').change(function(){
        var iframe_array = <?php echo  json_encode($variety);   ?>;
        var checkValue=jQuery("#exchange_id").val();
        $("#variety_id").empty();
        for (var i = 0; i <iframe_array.length ; i++)
        {
            if(iframe_array[i]['exchange_id']==checkValue)
            {
                var opt = "<option value='"+iframe_array[i]['id']+"'>"+iframe_array[i]['name']+"</option>";
                jQuery("#variety_id").append(opt);
            }
        }

    })
</script>

<script type="text/javascript">
    $('#d_exchange_id').change(function(){
        var iframe_array = <?php echo  json_encode($variety);   ?>;
        var checkValue=jQuery("#d_exchange_id").val();
        $("#d_variety_id").empty();
        for (var i = 0; i <iframe_array.length ; i++)
        {
            if(iframe_array[i]['exchange_id']==checkValue)
            {
                var opt = "<option value='"+iframe_array[i]['id']+"'>"+iframe_array[i]['name']+"</option>";
                jQuery("#d_variety_id").append(opt);
            }
        }

    })
</script>

<script type="text/javascript">
	
	$("#all1").change(function() { 

　　	    var chk = this.checked;

    		var ck_list = $("#con_table").find("input[type='checkbox']");

    		var len = ck_list.length;
    		//alert(len);
    		for (var i = 0; i < len; i++) {
        	if (chk == false) {
            	ck_list[i].checked = false;

        	}
        	else {
            	ck_list[i].checked = true;
        	}
    	} 
});
</script>
{/block}